egg-mode-text
like twitter-text, but in rust
This library is an attempt to port twitter-text to Rust. It was originally part of egg-mode, but
it's totally distinct from egg-mode type-wise, so i pulled it out into its own library. (Also it's
chock full of macros so it was also a bid to bring egg-mode's compile times down. >_>
)
This library can be used to count characters for tweets, and extract URLs and "entities" from arbitrary text, such as @-mentions and hashtags.
For example, to see how many characters a given tweet takes:
use character_count;
let count = character_count;
assert_eq!;
// URLs get replaced by a t.co URL of the given length
//
// This length is available from the Twitter API in `help/configuration`
let count = character_count;
assert_eq!;
// Multiple URLs get shortened individually
let count =
character_count;
assert_eq!;
To extract substrings of various "entities" used by Twitter:
use ;
let text = "sample #text with a link to twitter.com";
let mut results = entities.into_iter;
let entity = results.next.unwrap;
assert_eq!;
assert_eq!;
let entity = results.next.unwrap;
assert_eq!;
assert_eq!;
assert_eq!;
For more information, check out the documentation.
To use this crate in your own project, add the following to your Cargo.toml:
[]
= "1.15.1"
...and add the following to your crate root:
extern crate egg_mode_text;
License
egg-mode-text is licensed under the Mozilla Public License, version 2.0. See the LICENSE file for details.